<template>
  <basic-container>
    <avue-crud
        v-if="tableOption"
        v-bind="bindVal"
        v-on="onEvent"
        @cell-dblclick="rowDblclick"
        v-model:page="page"
        v-model="startForm">
      <!--      <template #menu="{size,row,index}">-->
      <!--        <el-dropdown-item divided    >自定义按钮</el-dropdown-item>-->
      <!--      </template>-->
<!--      <template #menu="{size,row,index}">-->

<!--        <el-button text-->
<!--                   type="primary"-->
<!--                   @click="designForm(row)"-->
<!--                   icon="el-icon-edit"-->
<!--        >设计-->
<!--        </el-button>-->
<!--        <el-button text-->
<!--                   type="primary"-->
<!--                   @click="viewData(row)"-->
<!--                   icon="el-icon-search"-->
<!--        >查看数据-->
<!--        </el-button>-->
<!--        <el-button text v-if="row.syncDataBase===false"-->
<!--                   type="primary"-->
<!--                   @click="syncDataBaseFrom(row)"-->
<!--                   icon="el-icon-refresh"-->
<!--        >同步表单-->
<!--        </el-button>-->
<!--        <el-button text v-if="row.createMenu===false"-->
<!--                   type="primary"-->
<!--                   @click="createMenu(row)"-->
<!--                   icon="el-icon-circle-plus-outline"-->
<!--        >创建菜单-->
<!--        </el-button>-->

<!--      </template>-->

      <template #menuBtn="{size,row,type}">
        <el-dropdown-item icon="el-icon-edit" :size="size"
                          @click.native="designForm(row)" :type="type">设计
        </el-dropdown-item>
        <el-dropdown-item icon="el-icon-search" :size="size"
                          @click.native="viewData(row)" :type="type">查看数据
        </el-dropdown-item>
        <el-dropdown-item v-if="row.isSyncDataBase===0"
                          @click.native="syncDataBaseFrom(row)"
                          icon="el-icon-refresh" :size="size"
                          :type="type">同步表单
        </el-dropdown-item>
        <el-dropdown-item v-if="row.isCreateMenu===0" divided icon="el-icon-circle-plus-outline" :size="size"
                          @click.native="createMenu(row)" :type="type">创建菜单
        </el-dropdown-item>

      </template>
    </avue-crud>

    <ActFormDesign ref="design" @submit="refreshChange"></ActFormDesign>
    <!--        <create-menu ref="createMenu" @change="refreshChange"></create-menu>-->
  </basic-container>
</template>

<script>

import {createDynamicMixin} from "../../../../mixins/startCrud.js";
// import createMenu from "./createMenu.vue";
import actFormApi from "../../../../api/start/activiti/actFormApi";
import ActFormDesign from "./actFormDesign.vue";

const option = {
  name: "start/activiti/actForm"
}
export default {
  mixins: [createDynamicMixin(option)],
  components: {
    ActFormDesign
    // createMenu
  },
  created() {

  },
  methods: {
    beforeOpenAddDialog(form, done) {
      this.$refs.design.design()

    },
    designForm(row) {
      this.$refs.design.design(row.id)
    },
    viewData(row) {
      this.$refs.design.design(row.id)
    },
    createMenu(row) {
      this.$refs.createMenu.show(row)
    },
    rowDblclick(row, column) {
      this.$refs.startTableCrud.rowEdit(row, row.$index)
    },
    shareForm(row) {
      this.$refs.createShare.show(row);
    },
    syncDataBaseFrom(row) {
      this.$confirm(`此操作将可能导致【${row.name}】表单数据丢失！, 是否继续?`, '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        return actFormApi.synchronizationTable(row.id)
      }).then(res => {
        this.$message({
          showClose: true,
          message: '同步成功',
          type: 'success'
        });
        this.loadRemoteDataSources()
      })
    }
  }
}
</script>

<style scoped>

</style>
